/*
	This file is part of CLISRServer.
	Foobar is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.
	
	CLISRServer is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.
	
	You should have received a copy of the GNU General Public License
	along with CLISRServer.  If not, see <http://www.gnu.org/licenses/>.
*/

#include <stdio.h>
#include <string.h>
#include <CUnit/Basic.h>
#include"SRPluginLoader.h"

int init_suite2(void)
 {
   return 0;
 }

int clean_suite2(void)
 {
  return 0;
 }

void testinitiate(void)
 {
/*	void* p;
	SRPluginLoader *loader = new SRPluginLoader("../../../clisrserver/plugins/vlc/plugin.so");
	SRPlugin *plug = loader -> getLastPlugin();
	CU_ASSERT(plug-> initiate() == 0);
 */} 



void testdestroy(void)
 { /*
	SRPlugin *plug = new SRPlugin();
	SRPluginLoader *loader = new SRPluginLoader("../../../clisrserver/plugins/vlc/plugin.so");
	loader -> destroy();
	SRPlugin* plugin = loader -> getLastPlugin();
	CU_ASSERT(plugin == NULL)
 */} 

void testdoCommand(void)
 {
	SRPluginLoader *loader = new SRPluginLoader("../../../clisrserver/plugins/vlc/plugin.so");
	SRPlugin *plug = loader -> getLastPlugin();
	CU_ASSERT(strcmp(plug -> doCommand("play-/home/paladi/sample_mpeg4.mp4"), "done play") == 0);
 } 


int main()
 {
   CU_pSuite pSuite = NULL;

   /* initialize the CUnit test registry */
   if (CUE_SUCCESS != CU_initialize_registry())
      return CU_get_error();

   /* add a suite to the registry */
   pSuite = CU_add_suite("Suite_2", init_suite2, clean_suite2);
   if (NULL == pSuite) {
      CU_cleanup_registry();
      return CU_get_error();
   }

   /* add the tests to the suite */
   if ((NULL == CU_add_test(pSuite, "test of initiate()", testinitiate)) ||
       (NULL == CU_add_test(pSuite, "test of destroy()", testdestroy)) ||
	(NULL == CU_add_test(pSuite, "test of doCommand()", testdoCommand)))
   {
      CU_cleanup_registry();
      return CU_get_error();
   }

   /* Run all tests using the CUnit Basic interface */
   CU_basic_set_mode(CU_BRM_VERBOSE);
   CU_basic_run_tests();
   CU_cleanup_registry();
   return CU_get_error();
 }
